<?php foreach ($list as $k => $v) { ?>
    <tr>
        <td class="billdate">
            <?php if ($v['task_id']) { ?>
                <a href="javascript:;" class="ftask" rel="<?= $v['task_id'] ?>" title="来自定时记账">定</a>
            <?php } ?>
            <a href="javascript:;" title="点击筛选分类数据" class="fdate" style="<?= $v['occurtime'] >= get_unixtime('day', -2) ? "color:#EC4F4F" : '' ?>" rel="<?= date("Y-m-d", $v['occurtime']) ?>"><?= date("Y-m-d", $v['occurtime']) ?></a>
        </td>
        <?php if ($type == 'transfer' || $type == 'credit') { ?>
        <?php } else if ($type == 'borrow') { ?>
            <td><a href="javascript:;" title="点击筛选该分类数据" class="fcategory" rel="<?= $v['category_id'] ?>"><?= get_borrow_category_name($v['category_id']) ?></a></td>
        <?php } else { ?>
            <td><a href="javascript:;" title="点击筛选该分类数据" class="fcategory" rel="<?= $v['father_category']['id'] ?>"><?= $v['father_category']['name'] ?></a> - 
                <a href="javascript:;" title="点击筛选该分类数据" class="fcategory" rel="<?= $v['category']['id'] ?>"><?= $v['category']['name'] ?></a></td>
        <?php } ?>
        <td><a href="javascript:;" title="点击筛选该账户数据" class="faccount" rel="<?= $v['account']['id'] ?>"><?= $v['account']['name'] ?></a></td>
        <?php if ($type == 'transfer') { ?>
            <td><a href="javascript:;" title="点击筛选该账户数据" class="faccount" rel="<?= $v['inaccount']['id'] ?>"><?= $v['inaccount']['name'] ?></a></td>
        <?php } else if ($type == 'credit') { ?>
            <td><a href="javascript:;" title="点击筛选该账户数据" class="faccount" rel="<?= $v['inaccount']['id'] ?>"><?= $v['inaccount']['name'] ?></a></td>
        <?php } ?>
        <td style="<?= in_array($type, array('income')) || ($type == 'borrow' && $v['outstanding'] == 0) ? "color:green" : (in_array($type, array('transfer', 'credit')) ? '' : 'color:#EC4F4F') ?>"><?= $v['amount'] ?></td>
        <?php if ($type == 'borrow') { ?>
            <td style="<?= $v['outstanding'] > 0 ? 'color:#EC4F4F' : 'color:gray' ?>"><?= $v['outstanding'] ?></td>
        <?php } ?>
        <td><?= $v['memo'] ?></td>
        <td>
            <?php if ($v['user_id'] == $user['id']) { ?>
                <?php if ($type == 'borrow') { ?>
                    <?php if ($v['category_id'] < 3) { ?>
                        <?php if ($v['outstanding'] > 0) { ?>
                            <a href="/bill/settle/<?= $v['id'] ?>/" class="dialog" callback="bill_pager_callback" cache="false" title="结清">结清</a>
                        <?php } else { ?> 
                            <a href="/bill/settle/<?= $v['id'] ?>/show/" class="dialog" title="详情">已结</a>
                        <?php } ?> 
                        <a href="/bill/settle/<?= $v['id'] ?>/show/" class="dialog" title="详情">详情</a>
                    <?php } ?> 
                <?php } else { ?> 
                    <a href="/bill/edit/<?= $v['id'] ?>/" class="dialog" callback="bill_pager_callback" title="修改记账" cache="false">修改</a> 
                <?php } ?>
                <a href="/bill/del/<?= $v['id'] ?>/" class="del" callback="bill_pager_callback">删除</a> 
            <?php } else { ?>
                <font color="gray">无法编辑</font>
            <?php } ?>
        </td>
    </tr>
<?php } ?>
<tr>
    <td colspan="6" style="padding:0;">
        <div class="pager graybg billpager">
            <?= $pagelist ?> 
        </div>
    </td>
</tr>
<script type="text/javascript">
    KS.common.load('bill.ajax');
</script>